<template>
	<view>
		<custom-header title="账单结算" />
		<view class="tabs_wrap">
			<view 
				class="list" 
				:class="tab == item.id?'active':''" 
				v-for="(item,index) in tabsList" 
				:key="index"
				@click="handleTab(item)">
				{{ item.name }}
			</view>
		</view>
		<scroll-view
			:scroll-y="true" 
			scroll-with-animation
			:style="{height:'calc(100vh - 85rpx - '+statusBarHeight+'px)'}"
			class="scroll_content_wrap">
				<view class="_wrap">
					<view
						class="no_data" 
						:style="{height:'calc(100vh - 200rpx - '+statusBarHeight+'px)'}"
						v-if="!listData.length && listLoading != 'loading'">
							<view class="icon">
								<image src="https://goods-1312936761.cos.ap-chongqing.myqcloud.com/applet/supplier/my/nodata.png" mode=""></image>
							</view>
					</view>
					<view class="list_wrap" v-else-if="listData.length">
						<view 
							class="list" 
							v-for="(item,index) in listData" 
							:key="index">
								<view class="status">
									<image src="/static/my/yjs.png" mode="" v-if="item.status == 1"></image>
									<image src="/static/my/wjs.png" mode="" v-else></image>
								</view>
								<view class="createTime">
									<view class="icon">
										<image src="/static/common/date_icon.png" mode=""></image>
									</view>
									<view class="text">2025-04-15</view>
								</view>
								<view class="buyer"> 买家：2位/6扎 </view>
								<view class="average_price"> 均价：￥12.33 </view>
								<view class="cost">
									<text>服务费：￥4.44</text>
									<text>运费：￥3.00</text>
									<text>理赔：￥0.00</text>
								</view>
								<view class="total_price">
									<view class="total">
										交易合计：<text>￥74.00</text>
									</view>
									<view class="price">
										结算金额：<text>￥74.00</text>
									</view>
								</view>
								<view class="btn" @click="handleDetail(item)">查看详情</view>
						</view>
					</view>
					<view class="loading_wrap" v-if="listLoading == 'loading'">
						<up-loadmore
							:status="listLoading"
							iconSize="22"
							iconColor="#FF3316"
							loadingIcon='semicircle'
							loadingText=""
							/>
					</view>
				</view>
		</scroll-view>
	</view>
</template>

<script setup>
	import { computed, ref , onMounted} from 'vue';
	import { useStore } from 'vuex';
	const store = useStore()
	
	const statusBarHeight = computed(()=>{
		return store.getters.statusBarHeight
	})
	
	const tab = ref(1)
	const tabsList = ref([
		{ id:1,name:'本月' },
		{ id:2,name:'全部' },
	])
	// 选择tabs
	const handleTab = (e)=>{
		console.log(e)
		tab.value = e.id
		loadGetListData()
	}
	
	// 获取列表数据
	const listLoading = ref('loadmore');
	const listData = ref([]);
	const loadGetListData = ()=>{
		listData.value = []
		listLoading.value = 'loading'
		setTimeout(()=>{
			listData.value = [
				{ id:1,status:1 },
				{ id:1,status:2 },
				{ id:1,status:2 },
				{ id:1,status:1 },
				{ id:1,status:1 },
				{ id:1,status:1 },
			]
			listLoading.value = 'loadmore'
		},1000);
	};
	const handleDetail = (item)=>{
		uni.navigateTo({
			url:'/pages/billSettlementDetail/billSettlementDetail?id='+item.id
		})
	}
	
	
	onMounted(()=>{
		loadGetListData();
	})
</script>

<style lang="scss">
	.tabs_wrap{
		display: flex;
		height: 82rpx;
		.list{
			flex: 1;
			text-align: center;
			padding: 20rpx 0;
			color: #999;
			font-size: 32rpx;
			position: relative;
			&.active{
				color: #333333;
				font-weight: bold;
				&::after{
					content: '';
					width: 28rpx;
					height: 8rpx;
					background: #FF3316;
					border-radius: 8rpx;
					position: absolute;
					bottom: 8rpx;
					left: 50%;
					margin-left: -14rpx;
				}
			}
		}
	}
	._wrap{
		padding: 20rpx;
	}
	.no_data{
		background: #fff;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		// margin: 20rpx;
		height:calc(100% - 40rpx);
		.icon{
			width: 280rpx;
			height: 322rpx;
		}
	}
	.list_wrap{
		.list{
			padding: 25rpx;
			background: #fff;
			font-size: 28rpx;
			color: #333333;
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			position: relative;
			.status{
				position: absolute;
				width: 173rpx;
				height: 140rpx;
				right: 37rpx;
				top: 25rpx;
			}
			.createTime{
				display: flex;
				align-items: center;
				.icon{
					width: 28rpx;
					height: 27rpx;
					display: flex;
				}
				.text{
					padding-left: 10rpx;
				}
			}
			.buyer,.average_price{
				padding-top: 20rpx;
			}
			.cost{
				display: flex;
				justify-content: space-between;
				font-size: 26rpx;
				color: #999;
				padding-top: 20rpx;
			}
			.total_price{
				display: flex;
				justify-content: space-between;
				padding-top: 20rpx;
				text{
					color: #C60C0C;
				}
			}
			.btn{
				margin-top: 20rpx;
				height: 68rpx;
				text-align: center;
				line-height: 68rpx;
				border-radius: 117rpx;
				background: #FFF0F0;
				color: #F5564D;
			}
		}
	}
</style>
